/*           Copyright(c) 2007-2008 Dave Sexton            *
 *                   XmlTreeView Control                   *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

namespace DaveSexton.Controls
{
	/// <summary>
	/// Provides event arguments for the <see cref="XmlTreeView"/> control.
	/// </summary>
	[Serializable]
	public class XmlTreeNodePlacementEventArgs : XmlTreeNodeEventArgs
	{
		#region Public Properties
		public NodePlacement Placement
		{
			get
			{
				return placement;
			}
		}

		public XmlTreeNode OriginalNode
		{
			get
			{
				return originalNode;
			}
		}

		public XmlTreeNode AdjacentNode
		{
			get
			{
				return adjacentNode;
			}
		}
		#endregion

		#region Private / Protected
		private readonly NodePlacement placement;
		private readonly XmlTreeNode originalNode, adjacentNode;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="XmlTreeNodePlacementEventArgs" /> class.
		/// </summary>
		public XmlTreeNodePlacementEventArgs(XmlTreeNode node, NodePlacement placement, XmlTreeNode adjacentNode)
			: base(node)
		{
			// NOTE: null adjacentNode indicates the root

			if (!Enum.IsDefined(typeof(NodePlacement), placement))
				throw new InvalidEnumArgumentException("placement", (int) placement, typeof(NodePlacement));

			this.originalNode = node;			// The OriginalNode and Node properties are the same unless the other constructor is used
			this.adjacentNode = adjacentNode;
			this.placement = placement;
		}

		/// <summary>
		/// Constructs a new instance of the <see cref="XmlTreeNodePlacementEventArgs" /> class.
		/// </summary>
		public XmlTreeNodePlacementEventArgs(XmlTreeNode originalNode, XmlTreeNode node, NodePlacement placement, XmlTreeNode adjacentNode)
			: this(node, placement, adjacentNode)
		{
			this.originalNode = originalNode;
		}
		#endregion
	}
}
